{include file="public/header" /}
<div class="page">
<form method="post" name="remark_form" id="remark_form">
    <input type="hidden" name="order_id" value="{$order_id}">
    <input type="hidden" name="num" value="{$num}">
	<tfoot>
            <tr class="tfoot" > 
                <td colspan="2">
                    <input  style="margin-left: 11px; margin-top: 18px;line-height: 20px;" type='submit' class="btn"  value="开始拆单" />
                </td>
            </tr>
    <table class="ds-default-table">
        <input type='hidden' name="oid"  value="{$order_id}"/>
       <thead>
            <tr>
                <th class="w60 align-center"></th>
                <th>设备名称</th>
                <th>品牌</th>
                <th>型号</th>
                <th>备注</th>
            </tr>
        </thead>
        <tbody>
             {foreach name="childOrders" item="v"}
             <tr> 
                <td class="w24">
                    <input type="checkbox" class="checkitem" name="chaidanIds[]" value="{$v.id}">
                </td>
                <td>{$v.goods_name}</td>
                 <td>{$v.b_name}</td>
                <td class="w180"> {$v.type_model}</td>
                 <td>{$v.remark}</td>

              </tr> 
              
            {/foreach}
        </tbody>
        
        </tfoot>
    </table>
</form>

</div>
<script type="text/javascript" src="{$Think.ADMIN_SITE_ROOT}/js/jquery.edit.js" charset="utf-8"></script>
<script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/jquery.mousewheel.js"></script>
<script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/mlselection.js" charset="utf-8"></script>

<script src="{$Think.ADMIN_SITE_ROOT}/js/question.js"></script>
<script type="text/javascript" src="{$Think.ADMIN_SITE_ROOT}/js/jquery.edit.js" charset="utf-8"></script>
<script type="text/javascript">

    //查看详情
    function goods_setting_info_jia(ids_str) {
        _uri = ADMINSITEURL+"/Goods/goods_setting_info?commonid=" + ids_str;
        dsLayerOpen(_uri,'查看详情','900px','680px');
    }
    $(function(){
        //商品分类
        /* AJAX选择品牌 */
        $("#ajax_brand").brandinit();

        $('#dssubmit').click(function(){
            $('#formSearch').submit();
        });

        // 审核批量处理
        $('a[dstype="verify_batch"]').click(function(){
            ids_str = getItems();
            if (ids_str) {
                goods_verify(ids_str);
            }
        });
        // 违规下架批量处理
        $('a[dstype="lockup_batch"]').click(function(){
            ids_str = getItems();
            if (ids_str) {
                goods_lockup(ids_str);
            }
        });

        // ajax获取商品列表
        $('i[dstype="ajaxGoodsList"]').click(
            function(){

                var status = $(this).attr("status");
                if (status == 'open') {
                    $(this).attr('status', 'close');
                    $(this).removeClass('icon-jia').addClass('icon-jian');
                    var _parenttr = $(this).parents('tr');
                    var _commonid = $(this).attr('data-comminid');
                    var _div = _parenttr.next().find('.dssc-goods-sku');
                    if (_div.html() == '') {
                        $.getJSON('{:url("Goods/get_goods_list_ajax")}' , {commonid : _commonid}, function(date){
                            if (date != 'false') {
                                var _ul = $('<ul class="dssc-goods-sku-list"></ul>');
                                var res = eval('(' + date + ')');
                                for (var i = 0; i < res.length; i++)
                                {
                                    $('<li><div class="goods-thumb" title="{$Think.lang.goods_serial}：' + res[i].goods_serial + '"><a href="' + res[i].url + '" target="_blank"><image src="' + res[i].goods_image + '" ></a></div>' + res[i].goods_spec + '<div class="goods-price">{$Think.lang.goods_price}：<em title="￥' + res[i].goods_price + '">￥' + res[i].goods_price + '</em></div><div class="goods-storage">{$Think.lang.goods_storage}：<em title="' + res[i].goods_storage + '">' + res[i].goods_storage + '</em></div><a href="' + res[i].url + '" target="_blank" class="dssc-btn-mini">{$Think.lang.show_goods_detail}</a></li>').appendTo(_ul);
                                    _ul.appendTo(_div);
                                    _parenttr.next().show();
                                }

                                // 计算div的宽度
                                _div.css('width', document.body.clientWidth-54);

//                        _div.perfectScrollbar();
                            }
                        });
                    } else {
                        _parenttr.next().show()
                    }
                }else{
                    $(this).attr('status', 'open');
                    $(this).removeClass('icon-jian').addClass('icon-jia');
                    $(this).parents('tr').next().hide();
                }

            }
        );
    });

    // 获得选中ID
    function getItems() {
        /* 获取选中的项 */
        var items = '';
        $('.checkitem:checked').each(function () {
            items += this.value + ',';
        });
        if (items != '') {
            items = items.substr(0, (items.length - 1));
        }else{
            layer.alert('{$Think.lang.please_select_input}', {icon: 2})
        }
        return items;
    }

    // 商品下架
    function goods_lockup(ids_str) {
        _uri = ADMINSITEURL+"/Goods/goods_lockup?commonid=" + ids_str;
        dsLayerOpen(_uri,'{$Think.lang.goods_index_lock_reason}','400px','200px');
    }

    // 商品审核
    function goods_verify(ids_str) {
        _uri = ADMINSITEURL+"/Goods/goods_verify?commonid=" + ids_str;
        dsLayerOpen(_uri,'{$Think.lang.goods_verify}','400px','200px');
    }

    //商品设置平台价格
    function goods_setting_price(ids_str) {
        _uri = ADMINSITEURL+"/Product/goods_setting_price?commonid=" + ids_str;
        dsLayerOpen(_uri,'{$Think.lang.ds_setting_price}','1200px','800px');
    }

    //商品设置教程
    function goods_setting_course(ids_str) {
        _uri = ADMINSITEURL+"/Goods/goods_setting_course?commonid=" + ids_str;
        dsLayerOpen(_uri,'{$Think.lang.ds_setting_price}','400px','400px');
    }

    function submit_delete(ids_str){
        _uri = ADMINSITEURL+"/Goods/goods_del.html?common_id=" + ids_str;
        dsLayerConfirm(_uri,'{$Think.lang.ds_ensure_del}');
    }
        function getGcId1(gc_id1, select_id)
    {
        var select_od = select_id;
        $.ajax({
            type : "GET",
            contentType: "application/json;charset=UTF-8",
            url : ADMINSITEURL+"/Question/getClass.html?gc_id=" + gc_id1,
            success : function(result) {
                result = JSON.parse( result );
                var html = '<option value="">选择分类</option>';
                for(var i=0;i<result.length;i++){
                    if (result[i].gc_id == select_id) {
                        html += '<option selected value="'+ result[i].gc_id +'">'+ result[i].gc_name +'</option>'
                    } else {
                        html += '<option value="'+ result[i].gc_id +'">'+ result[i].gc_name +'</option>'
                    }
                }
                $('#search_gc_id2').html(html)
            },
            //请求失败，包含具体的错误信息
            error : function(e){
                console.log(e.status);
                console.log(e.responseText);
            }
        });
    }

    function getGcId2(gc_id1, select_id)
    {
        $.ajax({
            type : "GET",
            contentType: "application/json;charset=UTF-8",
            url : ADMINSITEURL+"/Question/getClass.html?gc_id=" + gc_id1,
            success : function(result) {
                result = JSON.parse( result );
                var html = '<option value="">选择分类</option>';
                for(var i=0;i<result.length;i++){
                    if (result[i].gc_id == select_id) {
                        html += '<option selected value="'+ result[i].gc_id +'">'+ result[i].gc_name +'</option>'
                    } else {
                        html += '<option value="'+ result[i].gc_id +'">'+ result[i].gc_name +'</option>'
                    }
                }
                $('#search_gc_id3').html(html)
            },
            //请求失败，包含具体的错误信息
            error : function(e){
                console.log(e.status);
                console.log(e.responseText);
            }
        });
    }
    //获取下级分类
    $('#search_gc_id1').on('change',function () {
        var gc_id1 = $(this).val();
        getGcId1(gc_id1)
    })

    $('#search_gc_id2').on('change',function () {
        var gc_id2 = $(this).val();
        getGcId2(gc_id2)
    })
</script>
{if $Request.param.search_gc_id1}
<script>

    // 编辑初始化，处理分类选中的问题
        var gc_id1 = '{$Request.param.search_gc_id1}';
        var gc_id2 = '{$Request.param.search_gc_id2}';
        var gc_id3 = '{$Request.param.search_gc_id3}';
        getGcId1(gc_id1, gc_id2)
        getGcId2(gc_id2, gc_id3)
</script>
{/if}